/*
 * Robot leg
 *
 * Created: 11/24/2013 8:23:01 AM
 *  Author: Ema and Nikash
 */ 


#include <Servo.h>

// create servo object to control two servos
Servo myservo1;
Servo myservo2;

int pos = 0;    // variable to store the servo position

void setup()
{
	// initialize the SERVO pins as an output:
	pinMode(8, OUTPUT);
	pinMode(10, OUTPUT);
	// attaches the servo on pins 8 and 10 to the servo object
	myservo1.attach(8);
	myservo2.attach(10);
}

void loop()
{
	
	for(pos = 10; pos < 170; pos += 1)  // goes from 10 degrees to 170 degrees
	{                                   // in steps of 1 degree
		myservo1.write(pos);            // tell servo to go to position in variable 'pos'
		delay(5);                       // waits 5ms for the servo to reach the position
	}
	
	for(pos = 10; pos < 170; pos += 1)  // goes from 10 degrees to 170 degrees
	{                                   // in steps of 1 degree
		myservo2.write(pos);            // tell servo to go to position in variable 'pos'
		delay(5);                       // waits 5ms for the servo to reach the position
	}
	
	for(pos = 170; pos>=10; pos-=1)     // goes from 170 degrees to 10 degrees
	{                                   // in steps of -1 degree
		myservo2.write(pos);            // tell servo to go to position in variable 'pos'
		delay(5);                       // waits 5ms for the servo to reach the position
	}
	
	for(pos = 170; pos>=10; pos-=1)     // goes from 170 degrees to 10 degrees
	{                                   // in steps of -1 degree
		myservo1.write(pos);            // tell servo to go to position in variable 'pos'
		delay(5);                       // waits 5ms for the servo to reach the position
	}
	
	
	delay(2000);                        // wait 2000 ms (2 sec)
	
}

